
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>浏览页面</title>
        <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
        <link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
    </head>
    <body class="pear-container">
    
        <!-- 顶部查询表单 -->

        <form class="layui-form">

            <div class="layui-card">
                <div class="layui-card-body">
                    <div>
                        <strong>收货人:</strong>
                        <?=$orderInfo['receive_contact']?>
                    </div>

                    <div>
                        <strong>联系方式:</strong>
                        <?=$orderInfo['receive_mobile']?>
                    </div>

                    <div>
                        <strong>收货地址:</strong>
                        <?=$orderInfo['receive_address']?>
                    </div>

                    <div>
                        <strong>订单备注:</strong>
                        <?=$orderInfo['remark']?>
                    </div>

                    <div>
                        <strong>支付方式:</strong>
                        <?=$orderInfo['pay_way_text']?>
                    </div>

                    <table class="layui-table">
                        <colgroup>
                            <col width="150">
                            <col width="200">
                            <col>
                        </colgroup>
                        <tr>
                            <td colspan="5">



                            </td>
                        </tr>
                        <thead>
                        <tr>
                            <th>产品名称</th>
                            <th>sku</th>
                            <th>购买数量</th>
                            <th>单价</th>
                            <th>合计</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($orderGoodsList as $list) : ?>
                        <tr>

                            <td><?=$list['goods_name']?></td>
                            <td><?=$list['sku']?></td>
                            <td><?=$list['count']?></td>
                            <td><?=$list['price']?></td>
                            <td><?=$list['count']*$list['price']?></td>
                        </tr>
                        <?php endforeach ?>

                        <tr>
                            <td colspan="6" align="right">
                                合计: <?=$orderInfo['price']?>
                            </td>
                        </tr>

                        <?php if ($orderInfo['pay_time'] && !$orderInfo['shipping_time'] && !$orderInfo['cancel_time']) : ?>
                        <tr style="height: 350px;">
                            <td colspan="6">
                                <div class="mainBox">
                                    <div class="main-container mr-5">


                                        <div class="layui-form-item">
                                            <label class="layui-form-label">物流公司</label>
                                            <div class="layui-input-block">
                                                <div name="express_company_id"  id="express_company_id" value="" ></div>
                                            </div>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">物流单号</label>
                                            <div class="layui-input-block">
                                                <input type="text"  lay-verify="required" name="express_no" value="" class="layui-input">
                                            </div>
                                        </div>

                                    </div>
                                </div>

                                <div class="bottom">
                                    <div class="button-container">
                                        <button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
                                            提交
                                        </button>
                                        <button type="reset" class="pear-btn pear-btn-md">
                                            重置
                                        </button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <?php endif ?>
                        </tbody>
                    </table>
                </div>
            </div>



        </form>



        <script src="/app/admin/component/layui/layui.js"></script>
        <script src="/app/admin/component/pear/pear.js"></script>
        <script src="/app/admin/admin/js/permission.js"></script>
        <script src="/app/admin/admin/js/common.js"></script>
        
        <script>

            // 相关常量
            const PRIMARY_KEY = "id";
            const SELECT_API = "/app/admin/order/select";
            const DELETE_API = "/app/admin/order/delete";
            const SHOW_API = "/app/admin/order/show";
            const INSERT_URL = "/app/admin/order/insert";
            const UPDATE_API = "/app/admin/order/update";

            layui.use(["form", "popup"], function () {
                // 字段验证允许为空
                layui.form.verify({
                    phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
                    email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
                    url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
                    number: [/(^$)|^\d+$/,'只能填写数字'],
                    date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
                    identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
                });
                layui.form.on("submit(save)", function (data) {
                    data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
                    layui.$.ajax({
                        url: UPDATE_API,
                        type: "POST",
                        dateType: "json",
                        data: data.field,
                        success: function (res) {
                            if (res.code) {
                                return layui.popup.failure(res.msg);
                            }
                            return layui.popup.success("操作成功", function () {
                                parent.refreshTable();
                                parent.layer.close(parent.layer.getFrameIndex(window.name));
                            });
                        }
                    });
                    return false;
                });
            });


            layui.use(["jquery", "xmSelect"], function() {
                layui.$.ajax({
                    url: "/app/admin/express-company/get",
                    dataType: "json",
                    success: function (res) {
                        let value = layui.$("#express_company_id").attr("value");
                        let initValue = value ? value.split(",") : [];
                        layui.xmSelect.render({
                            el: "#express_company_id",
                            name: "express_company_id",
                            initValue: initValue,
                            data: res.data,
                            model: {"icon":"hidden","label":{"type":"text"}},
                            clickClose: true,
                            radio: true,
                            searchable: true,
                            filterable: true
                        });
                        if (res.code) {
                            return layui.popup.failure(res.msg);
                        }
                    }
                });
            });

        </script>
    </body>
</html>
